<%-- 
    Document   : CadastroPedido
    Created on : 05/11/2014, 18:09:11
    Author     : W8
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="bootstrap-3.2.0/dist/css/bootstrap.css"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Cadastro de Pedidos</title>
        <script language="javascript" type="text/javascript">
            function iniciaAjax(){
                var objetoAjax = false;
                if(window.XMLHttpRequest){
                    objetoAjax = new XMLHttpRequest();
                }else if(window.ActiveXObject){
                    try {
                        objetoAjax = new ActiveXObject("Msxm12.XMLHTTP");
                    } catch(e){
                        try {
                            objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch(ex){
                            objetoAjax = false;
                        }
                    }
                }
                return objetoAjax;
            }
            
            var ini = iniciaAjax();
            
            
            function registrar(){
                var nome = document.getElementById("nome").value;
                var pedido = document.getElementById("pedido").value;
                
                var url ="http://localhost:8083/gerenciapedidos/gerenciapedidos?nome="+nome+"&pedido="+pedido;
                ini.open("get", url, true);
                ini.onreadystatechange = callback;
                ini.send(null);
            }
            
            function callback(){
                if(ini.readyState===4){
                    if(ini.status===200){
                        
                        document.getElementById("respostaServidor").innerHTML = ini.responseText;
                        alert(ini.responseText);
                    }
                }
            }
        </script>

    </head>
    <body>
        <h1>Cadastro do Pedido</h1>
        <form action="gerenciapedidos" method="get">
            <table class="table-hover">
                <tr class="table-bordered" ><td class="label-info" >Informe o seu pedido:</td></tr>
            <tr class="table-bordered" ><td class="label-info" >Nome: <input  class="input-sm" type="text" name="nome" value="" id="nome"/></td></tr>
            <tr class="table-bordered" ><td class="label-info" >Pedido: <input class="input-sm" type="text" name="pedido" value="" id="pedido"/></td></tr>
            <tr class="table-bordered" ><td class="label-info" align="right" ><input class="btn-success" type="button" value="Registrar Pedido" onclick="registrar();"/></td></tr>
            </table>
        </form>
        
        <div class="list-group-item" id="respostaServidor">
            Receber conteúdo:
        </div>
    </body>
</html>
